<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li v-for="(item,index) in newList" :key="index" :class="{completed:item.isDone}" >
      <div class="view">
        <input v-model="item.isDone" @input="changisDone(index)" class="toggle" type="checkbox" />
        <label>{{item.name}}</label>
        <button @click="$store.commit('removeList',index)" class="destroy"></button>
      </div>
    </li>
  </ul>
  
</template>

<script>
import { mapState,mapGetters } from 'vuex'
export default {
  computed:{
    ...mapState(['myList']),
    ...mapGetters(['newList'])
  },
  methods:{
    changisDone(i){
      this.$store.commit('changeIsDone', i)
    }
  }
}
</script>
